package lei_tao;

public class LEI_TAO_23_Q1<T> {
    private int length;
    private Node <T> head;
    private Node  <T> top;
    public LEI_TAO_23_Q1(){
        head = new Node(null,null,null);
        top =head;
    }
    class Node<T> {
        T t;
        Node next;
        Node before;

        public Node(T t, Node next,Node before) {
            this.t = t;
            this.next = next;
            this.before=before;
        }
    }
    public void insert(T t){
        top.next = new Node(t,null,top);
        top =top.next;
        length++;

    }
    public void  delate(int x){
        if (x>this.length||x<0){
            System.out.println("越界");
        }
        for (int i = 0; i < x; i++) {
            top =top.before;
            length--;

        }
    }

    public static void main(String[] args) {
        LEI_TAO_23_Q1 stack = new LEI_TAO_23_Q1();
        stack.insert("7");
        stack.insert("8");
        stack.insert("9");
        stack.insert("10");
        stack.delate(1);
        System.out.println(stack.top.t);

    }
}
